home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / futils.arc / FBIOS.DOC next >
Text File  |  1991-04-28  |  9KB  |  263 lines

  1.  
  2. ********************************************************************
  3. ************************* FBIOS by Rex Kerr ************************
  4. ************************ Copyright (C) 1989 ************************
  5. ********************************************************************
  6.  
  7. This is a small unit for Turbo Pascal 5.5 written in assembly
  8. language.  I wrote it in assembly language for two reasons:
  9.  
  10. 1) I wanted it as fast as I could have it
  11. 2) I wanted it as small as I could have it
  12.  
  13. So I wrote it in assembly language.  Programming in assembler,
  14. compared with programming in pascal, is tedious, boring, and
  15. "dangerous."  But it has advantages that cannot be overlooked.  It
  16. produces tiny code, and is far more flexible that Pascal.  I
  17. purposely haven't included any of the "dangerous" BIOS interrupts
  18. (like disk service) because they are too hard to test and debug
  19. (not to mention use!).  So here are 22 of the most commonly used
  20. BIOS routines:
  21.  
  22. ***
  23.  
  24. BiosPrintScr;
  25.  
  26. This simply does a PrtSc.  Nothing more, nothing less.
  27.  
  28. ***
  29.  
  30. BiosSetVidMode(valu : byte);
  31.  
  32. This sets the video mode.
  33. The modes are:
  34.   0 : 40 * 25 black & white text
  35.   1 : 40 * 25 color text
  36.   2 : 80 * 25 black & white text
  37.   3 : 80 * 25 color text
  38.   4 : 320 * 200 4 color graphics (2 palettes)
  39.   5 : 320 * 200 black & white graphics
  40.   6 : 640 * 200 black & white graphics
  41.   7 : 80 * 25 monochrome text
  42.   8 : 160 * 200 16 color graphics (PCjr)
  43.   9 : 320 * 200 16 color graphics (PCjr)
  44.  10 : 640 * 200 4 color graphics (PCjr)
  45.  (no 11 or 12, as far as I know)
  46.  13 : 320 * 200 16 color graphics (EGA)
  47.  14 : 640 * 200 16 color graphics (EGA)
  48.  15 : 640 * 350 monochrome graphics (EGA)
  49.  16 : 640 * 350 color graphics.  4 colors with 64k EGA RAM,
  50.                                  16 colors with 128k or more
  51.  17 : 640 * 480 2 color graphics (MCGA and VGA)
  52.  18 : 640 * 480 16 color graphics (VGA)
  53.  19 : 320 * 200 256 color graphics (MCGA and VGA)
  54.  
  55. ***
  56.  
  57. BiosCurShape(start,stop : byte);
  58.  
  59. This sets the shape of the cursor.  Lines are numbered 0 to 7 on
  60. CGAs and 0 to 13 on monochrome.  The normal cursor is 6 and 7 (CGA)
  61. or 12 and 13 (monochrome).  You can make the cursor dissapear by
  62. setting start to 32.
  63.  
  64. ***
  65.  
  66. BiosGetCur(var start,stop : byte);
  67.  
  68. This gets the shape of the cursor.  See BiosCurShape above.
  69.  
  70. ***
  71.  
  72. BiosGotoxy(x,y : byte);
  73.  
  74. This positions the cursor just like TP's GotoXY does.  But BIOS
  75. always has the full screen as its window.  Therefore, I use GotoXY
  76. for window-relative gotos and BiosGotoXy for screen-relative gotos.
  77.  
  78. ***
  79.  
  80. BiosGetxy(var x,y : byte);
  81.  
  82. This gets the position of the cursor in screen coordinates.  See
  83. BiosGotoxy
  84.  
  85. ***
  86.  
  87. BiosScroll(lines : shortint; x,y,w,h : byte; attr : byte);
  88.  
  89. This lets you define a window with X,Y,W,H and scroll it up the
  90. number of lines specified.  To scroll down, set a negative number.
  91. Any new lines resulting from scrolling will be blank and in
  92. the text attributes of attr.  If you are using the CRT unit in your
  93. program, you can have the new attributes the same as the ones in TP
  94. by putting the CRT variable textattr in for the attr byte.
  95.  
  96. example:  BiosScroll(-2,1,1,80,25,textattr);  { Scrolls whole screen
  97.                                                 down 2 lines in current
  98.                                                 TP text attribute }
  99.  
  100. ***
  101.  
  102. BiosChar(ch : char; attr : byte);
  103.  
  104. This writes ch to the screen in attr at the current position of the
  105. cursor.  The cursor is NOT updated, and no characters are
  106. interpreted.  In other words, bioschar(^G,textattr) would write
  107. ASCII character #7 to the screen, whereas write(^G) would sound a
  108. short beep.
  109.  
  110. ***
  111.  
  112. BiosGetChar(var ch : char; var attr : byte);
  113.  
  114. This reads ch and attr from the screen at the current cursor
  115. position.  The cursor is not updated; see BiosChar.
  116.  
  117. ***
  118.  
  119. BiosJustChar(ch : char; rpts : word);
  120.  
  121. This repeats ch the number of times specified.  The cursor is not
  122. updated.  See BiosChar.
  123.  
  124. ***
  125.  
  126. BiosCookedChar(ch : char);
  127.  
  128. This writes one character at the current cursor position, updates
  129. the cursor, and interprets bell, backspace, line feed, and
  130. carriage return characters.  It also correctly handles screen
  131. scrolling and line wrapping.
  132.  
  133. ***
  134.  
  135. BiosPutPixel(colr : byte; x,y : word);
  136.  
  137. This writes a pixel of color colr to the screen at X,Y.  You must
  138. be in graphics mode.  I do not recommend using this, however!  It
  139. is both slower and less portable than the Turbo Graph unit.  But,
  140. it IS smaller, so if you are really really tight on space and only
  141. want to draw a few dots or lines (or other simple things), it might
  142. do.
  143.  
  144. ***
  145.  
  146. BiosGetPixel(x,y : word) : byte;
  147.  
  148. This function returns the color of the pixel at X,Y.  See
  149. BiosPutPixel.
  150.  
  151. ***
  152.  
  153. BiosGetVidMode : byte
  154.  
  155. This function return the current video mode.  See BiosSetVidMode.
  156.  
  157. ***
  158.  
  159. BiosEquip : word;
  160.  
  161. This returns the BIOS's equipment list.  Here's how to decode the
  162. word:
  163.  
  164. Bits in word     Use          To get them at the beginning of a word
  165.    15,14     # of printers      w := w shr 14;
  166.    13        not used
  167.    12        Game I/O attached  w := w and $1000; w := w shr 12;
  168.    11,10,9   # of RS-232        w := w and $0E00; w := w shr 9;
  169.    8         not used
  170.    7,6       # of disk drives   w := (w and $00C0) shr 6; inc(w);
  171.    5,4       Initial video mode w := (w and $0030) shr 4;
  172.    3,2       Amount of RAM      w := (w and $000C) shr 2; inc(w);
  173.                                 w := w shl 4;
  174.    1         not used
  175.    0         Any disk drives?   w := w and $0001;
  176.  
  177. If bit 0 = 0 then there are NO disk drives; otherwise the number in
  178. bits 7,6 is right.  3,2 contains the amount of ram on the motherboard
  179. (whatever you want that for) in kbytes.  Bits 5,4 contain the
  180. startup video configuration.  1 = 40 by 25 CGA, 2 = 80 by 25 CGA,
  181. and 3 = 80 by 24 monochrome.  This is a complex interrupt; for more
  182. information, you can look it up in any good book on advanced
  183. MS-DOS or in the BIOS Technical Reference manual.  (By the way,
  184. it is interrupt $11.)
  185.  
  186. ***
  187.  
  188. BiosReadKey : word;
  189.  
  190. This is not a duplicate of Turbo's ReadKey.  For one thing, you
  191. never have to read twice to get one key.  The low byte of the
  192. word is the ASCII code returned, and the high byte is the scan
  193. code returned.  There is a table of the scan codes on page 450
  194. of the TP5 Reference guide.  Some experimenting on your part may
  195. be necessary to get a better understanding of this function.
  196.  
  197. ***
  198.  
  199. BiosTestKey(var key : word) : boolean;
  200.  
  201. If there aren't any keys waiting to be processed, BiosTestKey will
  202. return false and leave key undefined.  If there is a key waiting to
  203. be processed, BiosTestKey will return true, and key will be set to
  204. the key waiting.  It will not be removed, however; you need to call
  205. BiosReadKey (or ReadKey) for that.
  206.  
  207. ***
  208.  
  209. BiosShiftStatus : byte;
  210.  
  211. This function returns the shift status byte of the computer.  Here
  212. is the bit map of the byte:
  213.        7 : Insert ON                 6 : CapsLock ON
  214.        5 : NumLock ON                4 : ScrollLock ON
  215.        3 : Alt DOWN                  2 : Ctrl DOWN
  216.        1 : Lft-Shft DOWN             0 : Rgt-Shft DOWN
  217. The byte is at location 0:$417 (in case you want to modify any
  218. of the 7-4 bits).  0:$417 is the same as $41:$7
  219.  
  220. ***
  221.  
  222. BiosPrintChar(prn_num : byte; ch : char) : byte;
  223.  
  224. Prn_num is the number of the printer to use (0 to 2 is valid),
  225. and ch is the character to print.  It returns a byte contaning
  226. the printer status.  Here is a bit map of that byte:
  227.        7 : Not busy                  6 : Acknowledge
  228.        5 : Out of paper              4 : Selected
  229.        3 : I/O error                 2 : *UNUSED*
  230.        1 : *UNUSED*                  0 : Time out
  231. I'm not sure what all of the codes mean, but you can always seem
  232. to write to the printer when bits 7 and 4 are on.
  233.  
  234. ***
  235.  
  236. BiosPrintInit(pnum : byte) : byte;
  237.  
  238. This initializes the printer.  You should not call this unless it
  239. is absolutely necessary, as it messes up any printing jobs running
  240. in the background.  See BiosPrintChar for the return codes.
  241.  
  242. ***
  243.  
  244. BiosPrintStatus(prn_num : byte) : byte;
  245.  
  246. This just returns the status byte of the specified printer
  247. (without printing a character).  It is good to call this before
  248. you print to see if you can or not.  See BiosPrintChar for the
  249. return codes.
  250.  
  251. ***
  252.  
  253. BiosClockCount : longint
  254.  
  255. This returns the current value of the clock count.  It is incremented
  256. roughly 18.2 times per second.  Another way to say it is that it
  257. is incremented 64k times (65536 times) per hour.
  258.  
  259. ***
  260.  
  261.    Any good book on MS-DOS or BIOS should cover these interrupts in
  262. more detail.  The one I use is MS-DOS Advanced Programming by
  263. Michael J. Young, published by Sybex.